package com.jinbei.config;

import com.gkoudai.crude.service.AccountHessianService;
import org.sojex.gold.remote.HessianGoldServer;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.remoting.caucho.HessianProxyFactoryBean;

import java.net.MalformedURLException;

/**
 * @author zflu
 * hessian调用配置
 * Created by lucky on 2018/9/17.
 */
@Configuration
public class HessianConfig {

    @Value("${hessian.url.goldServer}")
    String goldServerUrl;

    @Value(("${hessian.url.kunLunServer}"))
    String kunLunServerUrl;

    @Bean
    public HessianProxyFactoryBean hessianGoldClient() {
        HessianProxyFactoryBean factory = new HessianProxyFactoryBean();
        factory.setServiceUrl(goldServerUrl);
        factory.setServiceInterface(HessianGoldServer.class);
        return factory;
    }

    @Bean
    public HessianProxyFactoryBean hessianKulLunClient() throws MalformedURLException {
        HessianProxyFactoryBean factory = new HessianProxyFactoryBean();
        factory.setServiceUrl(kunLunServerUrl);
        factory.setServiceInterface(AccountHessianService.class);
        factory.setOverloadEnabled(true);
        return factory;
    }
}
